<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>SIMRI - Lista de Sensores</title>
</h:head>
<h:body onload="dlgAq.show()">
	<center>
		<f:view>
			<p:menubar>
				<p:submenu label="Sensor">
					<p:menuitem value="Consultar por Sensor" url="ConsultaSensor.xhtml" />
					<p:menuitem value="Consultar Aquisições"
						url="ConsultaAquisicao.xhtml" />
					<p:menuitem value="Listar todos os sensores"
						url="ListarSensores.xhtml" />
				</p:submenu>
			</p:menubar>
			<h3>Lista de Todos os Sensores:</h3>
			<h:form id="listarForm">
				<p:dataGrid id="panel" var="sensor"
					value="#{consultaSensorBean.sensores}" columns="3" rows="10"
					emptyMessage="Sem Sensores Cadastrados!">
					<p:column>
						<p:panel header="#{sensor.get(1)}">
							<p:panelGrid columns="1">
								<p:graphicImage value="images/img.png" />
								<h:outputText value="Local: #{sensor.get(3)}" />
								<p:commandLink update=":listarForm:display"
									oncomplete="dlgInfo.show()" ajax="true">
									<f:setPropertyActionListener
										target="#{consultaSensorBean.sensor}" value="#{sensor}" />
									<p:graphicImage value="images/info.png" />
									<h:outputText value="Informações" />
								</p:commandLink>
								<p:commandLink action="#{consultaAqBean.pesquisar}"
									ajax="false">
									<f:setPropertyActionListener
										target="#{consultaAqBean.entradaPesquisa}"
										value="#{sensor.get(0)}" />
									<f:setPropertyActionListener
										target="#{consultaAqBean.pesquisaSel}" value="0" />
									<f:setPropertyActionListener
										target="#{consultaAqBean.mostrarGrafico}" value="true" />
									<p:graphicImage value="images/search.png" />
									<h:outputText value="Aquisições" />
								</p:commandLink>
							</p:panelGrid>
						</p:panel>
					</p:column>
				</p:dataGrid>
				<p:dialog modal="true" widgetVar="dlgInfo">
					<p:panelGrid id="display" columns="2">
						<f:facet name="header">
							<p:graphicImage value="images/img.png" />
						</f:facet>
						<h:outputText value="ID Sensor:" />
						<h:outputText value="#{consultaSensorBean.sensor.get(0)}" />
						<h:outputText value="Nome:" />
						<h:outputText value="#{consultaSensorBean.sensor.get(1)}" />
						<h:outputText value="ID Tipo:" />
						<h:outputText value="#{consultaSensorBean.sensor.get(2)}" />
						<h:outputText value="Local:" />
						<h:outputText value="#{consultaSensorBean.sensor.get(3)}" />
						<h:outputText value="Descrição:" />
						<h:outputText value="#{consultaSensorBean.sensor.get(4)}" />
					</p:panelGrid>
				</p:dialog>
				<p:dialog modal="true" widgetVar="dlgAq" rendered="#{consultaAqBean.mostrarConsulta}">
					<p:ajax event="close" listener="#{consultaAqBean.onCloseDialog}"/>
					<p:dataTable id="tabAquisicoes" var="aq"
						value="#{consultaAqBean.aquisicoes}" paginator="true" rows="10"
						emptyMessage="Sem dados encontrados!">
						<f:facet name="header">
							<h2>Lista de Aquisições Encontradas:</h2>
						</f:facet>
						<p:columns value="#{consultaAqBean.colunas}" var="coluna"
							columnIndexVar="j">
							<f:facet name="header">#{coluna}</f:facet>
							<h:outputText value="#{aq[j]}" />
						</p:columns>
						<f:facet name="footer">
						Aquisições encontradas: #{fn:length(consultaAqBean.aquisicoes)}
						</f:facet>
					</p:dataTable>
					<p:lineChart id="grafAquisicoes"
						value="#{consultaAqBean.graficoModel}" legendPosition="ne" />
				</p:dialog>
			</h:form>
		</f:view>
	</center>
</h:body>
</html>
